<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>4.v-once指令</title>
    <!--  引入Vue  -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<!--
    v-once:只渲染一次，以后数据变化，dom元素不会更新
-->
    <!--  准备好一个容器  -->
    <div id="root">
        <h2 v-once>初始化的n值是{{n}}</h2>
        <h2>当前n值为{{n}}</h2>
        <button @click="n++">点我n+1</button>
    </div>
</body>

<script type="text/javascript">
new Vue({
    el: '#root',
    data: {
        n: 1
    }
})
</script>
</html>